with open('war_and_peace.txt', 'w', encoding='utf-8') as f:
    f.write("This is a test file.\n")
    f.write("War and Peace is a novel by Leo Tolstoy.\n")
    f.write("It is regarded as one of the greatest works of literature.\n")
    f.write("Peace, war, love, hate, life, death.\n")
    f.write("End of test.\n")